<?php
class File
{
	public $Table="tblfile";
	public $FileID;
	public $FileName;
	public $FilePath;
	public $FileType;
	public $Status;
	
	function loadByKey($id)
	{
		$ob=new ClassConnect();
		$sql="select * from `".$this->Table."` where FileID='".$id."'";
		$row=$ob->singleData($sql);
		$this->FileID=$row['FileID'];
		$this->FileName=$row['FileName'];
		$this->FilePath=$row['FilePath'];
		$this->FileType=$row['FileType'];
		$this->Status=$row['Status'];
	}
	function loadByKeyLang($id,$lang)
	{
		$ob=new ClassConnect();
		$sql="select * from `".$this->Table."` where FileID='".$id."'";
		$row=$ob->singleData($sql);
		$this->FileID=$row['FileID'];
		$this->FileName=$row['FileName'.$lang];
		
	}
	function getTable($dk)
	{
		$ob=new ClassConnect();
		$sql="select * from `".$this->Table."` $dk";
		$data=$ob->mutiData($sql);
		return $data;
	}
	function travel($dk)
	{
		$arr=array();
		$data=$this->getTable($dk);
		for($i=0;$i<count($data);$i++)
			array_push($arr,$data[$i]['FileID']);
		return $arr;
	}
	function insert($conn)
	{
		$ob=new ClassConnect();
		$this->FileID=$ob->getNextId($this->Table,"FileID");
		$field=array("FileID","FileName","FilePath","FileType","Status");
		$value=array($this->FileID,$this->FileName,$this->FilePath,$this->FileType,$this->Status);
		return $ob->insertData($conn,$this->Table,$field,$value);
	}
	function update($conn)
	{
		$ob=new ClassConnect();
		$field=array("FileID","FileName","FilePath","FileType","Status");
		$value=array($this->FileID,$this->FileName,$this->FilePath,$this->FileType,$this->Status);
		$where="FileID = '".$this->FileID."'";
		
		return $ob->updateData($conn,$this->Table,$field,$value,$where);			
	}
	function delete($conn)
	{
		$ob=new ClassConnect();		
		$where="FileID = '".$this->FileID."'";
		return $ob->deleteData($conn,$this->Table,$where);
			
	}
}
?>
